﻿<mui:ModernWindow x:Class="Bull.Plugins.Login.Views.LoginView"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:mui="http://firstfloorsoftware.com/ModernUI"
                  xmlns:attachedBehaviours="clr-namespace:Bull.Core.AttachedBehaviours;assembly=Bull.Core"
                  Title="Login"
                  Style="{StaticResource BlankWindow}" 
                  ResizeMode="NoResize"
                  WindowStartupLocation="CenterScreen"
                  Width="1280">
    <mui:ModernWindow.Resources>
        <Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource {x:Type PasswordBox}}">
            <Setter Property="Validation.ErrorTemplate">
                <Setter.Value>
                    <ControlTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Border BorderThickness="1" BorderBrush="Red" VerticalAlignment="Top">
                                <Grid>
                                    <AdornedElementPlaceholder x:Name="adorner" Margin="-1"/>
                                </Grid>
                            </Border>
                            <Border x:Name="errorBorder" Background="Red" Margin="8,0,0,0" CornerRadius="0" IsHitTestVisible="False">
                                <TextBlock Text="{Binding Path=ErrorContent}" />
                            </Border>
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </mui:ModernWindow.Resources>
    <Grid VerticalAlignment="Center" HorizontalAlignment="Center">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition  Width="600"/>
            </Grid.ColumnDefinitions>
            <TextBlock Text="Username" Grid.Row="0" Grid.Column="0" />
            <TextBox Grid.Row="0" Grid.Column="1" Margin="5,0,0,5" Text="{Binding Username, ValidatesOnDataErrors=True}" attachedBehaviours:FocusManagerAttachedBehaviour.ControlToFocus="{Binding ElementName=UsernameTextBox}" x:Name="UsernameTextBox"/>

            <TextBlock Text="Password" Grid.Row="1" Grid.Column="0" />
            <PasswordBox Grid.Row="1" Grid.Column="1" Margin="5,0,0,5" attachedBehaviours:PasswordBoxAttachedBehaviour.Password="{Binding Password, ValidatesOnDataErrors=True}" />

            <TextBlock Text="Application Key" Grid.Row="2" Grid.Column="0" />
            <TextBox Grid.Row="2" Grid.Column="1" Margin="5,0,0,5" Text="{Binding ApplicationKey, ValidatesOnDataErrors=True}"/>

            <TextBlock Text="CertificatePath Path" Grid.Row="3" Grid.Column="0" />
            <Grid Grid.Row="3" Grid.Column="1" Margin="5,0,0,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <TextBox Text="{Binding CertificatePath, Mode=OneWay, ValidatesOnDataErrors=True}" IsReadOnly="True" IsEnabled="False" Margin="0,0,5,0" />
                <Button Content="..." Command="{Binding ShowDialogCommand}" Margin="5,0,0,0" Grid.Column="1"/>
            </Grid>
            
            <TextBlock Text="Certificate Password" Grid.Row="4" Grid.Column="0" />
            <PasswordBox Grid.Row="4" Grid.Column="1" Margin="5,0,0,5" attachedBehaviours:PasswordBoxAttachedBehaviour.Password="{Binding CertificatePassword, ValidatesOnDataErrors=True}"/>

            <Grid Grid.Column="1" Grid.Row="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Button Content="Login" Command="{Binding LoginCommand}" Margin="5,0,5,0" IsDefault="True"/>
                <Button Content="Cancel" Command="{Binding CancelCommand}" Margin="5,0,5,0" Grid.Column="1" />
                <TextBlock Foreground="Red" Text="{Binding ErrorMessage}" VerticalAlignment="Center" Grid.Column="2"/>
            </Grid>
        </Grid>
    </Grid>
</mui:ModernWindow>
